﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using InversPong.Utilities;

namespace InversPong.Services
{
    class SimpleSpriteDrawer : DrawableGameComponent, ISpriteDrawer
    {

        public SimpleSpriteDrawer(Game game)
            : base(game)
        {
            DrawOrder = Order.SpriteLevel;
            game.Components.Add(this);
        }

        public void DrawObject(SpriteBatch spriteBatch, InversPong.Model.Object obj, Color color)
        {
            this.DrawObject(spriteBatch, obj, color, Vector2.Zero);

        }

        public void DrawObject(SpriteBatch spriteBatch, InversPong.Model.Object obj, Color color, Vector2 offset)
        {
            Texture2D texture = obj.LoadTexture(Game.Content);

            Vector2 realPosition = offset + obj.Position;
            spriteBatch.Draw(texture, new Rectangle((int)realPosition.X, (int)realPosition.Y, obj.Width, obj.Height), color);
        }
        protected override void LoadContent()
        {
            // Preload all graphics

        }

        public override void Draw(GameTime gameTime)
        {

        }
    }
}
